import gdb

class ListTraverseCommand(gdb.Command):
    def __init__(self):
        super(ListTraverseCommand, self).__init__("list-traverse", gdb.COMMAND_USER)
    
    def invoke(self, arg, from_tty):
        head = gdb.parse_and_eval(arg)  # 解析传入的链表头指针参数
        
        current = head
        while current != 0:
            data = current['size']  # 访问链表节点的数据成员
            print("size: ", data)
            
            current = current['next']  # 访问链表节点的next指针
    
ListTraverseCommand()
